export function hexToRGBA(color: string, opacity: any) {
  let sColor = color.toLowerCase();
  const reg = /^#([0-9a-f]{3}|[0-9a-f]{6})$/;
  if (sColor && reg.test(sColor)) {
    if (sColor.length === 4) {
      sColor = sColor.replace(/[0-9a-f]{1}/g, '$&$&');
    }
    sColor = sColor.substr(1).replace(/[0-9a-f]{2}/g, (res: string) => `${parseInt(res, 16)},`);
    return `rgba(${sColor}${opacity})`;
  }
  return sColor;
}

export function rgb() {
  const r = Math.floor(Math.random() * 256);
  const g = Math.floor(Math.random() * 256);
  const b = Math.floor(Math.random() * 256);
  return `rgb(${r},${g},${b})`;
}
